package com.example.myworkc;

import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import android.app.Fragment;
import android.widget.ListView;
import android.widget.SimpleAdapter;
import androidx.recyclerview.widget.RecyclerView;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;


public class contactBlankFragment extends Fragment {
    private RecyclerView recyclerView2;
    public contactBlankFragment() {
        // Required empty public constructor
    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View view = inflater.inflate(R.layout.contact_blank, container, false);
        String[] name={"甘雨","川普","辉夜","熊二"};
        int[] png={R.drawable.ganyu, R.drawable.d1,R.drawable.huiye, R.drawable.xionger};
        List<Map<String, Object>> listitem = new ArrayList<Map<String, Object>>();
        for (int i = 0; i < name.length; i++) {
            Map<String, Object> showitem = new HashMap<String, Object>();
            showitem.put("png", png[i]);
            showitem.put("name", name[i]);
            listitem.add(showitem);
        }
        SimpleAdapter myAdapter = new SimpleAdapter(view.getContext(), listitem, R.layout.item2, new String[]{"png", "name"}, new int[]{R.id.imageView_contact, R.id.textView_contact});
       ListView listView = view.findViewById(R.id.list_view);
        listView.setAdapter(myAdapter);
        return view;

    }
}